<?php
/**
 * Created by PhpStorm.
 * User: daojia
 * Date: 2020/5/8
 * Time: 17:09
 */

namespace app\common\model\store\shop;


use app\common\model\BaseModel;
use app\common\enum\pay\order\PayStatus as PayStatusTypeEnum;

class Payorder extends BaseModel
{
    protected $name = 'pay_order';
    /**
     * 获取当前模型属性
     * @return array
     */
    public static function getAttributes()
    {
        return [
            // 支付状态
            'pay_status' => PayStatusTypeEnum::data(),
        ];
    }
    /**
     * 关联门店表
     * @return \think\model\relation\BelongsTo
     */
    public function shop()
    {
        $module = static::getCalledModule() ?: 'common';
        return $this->BelongsTo("app\\{$module}\\model\\store\\Shop");
    }
    /**
     * 关联用户表
     * @return \think\model\relation\BelongsTo
     */
    public function user()
    {
        $module = static::getCalledModule() ?: 'common';
        return $this->BelongsTo("app\\{$module}\\model\\User");
    }
    /**
     * 付款状态
     * @param $value
     * @return array
     */
    public function getPayStatusAttr($value)
    {
        return ['text' => PayStatusTypeEnum::data()[$value]['name'], 'value' => $value];
    }
}